﻿using System;
using System.Windows.Forms;
using 售后客户管理.Forms.InternalSetting;

namespace 售后客户管理.Forms
{
    public partial class FmInternalSetting : Form
    {
        public FmInternalSetting()
        {
            InitializeComponent();
        }

        private void FmInternalSetting_Load(object sender, EventArgs e)
        {
            AddMenu("sqlConfig", "数据库配置");
            AddMenu("userSetting", "用户配置");
            AddMenu("Columns", "字段维护");
            AddMenu("Dictionary", "字段字典维护");
        }
        private void AddMenu(string menuName, string menuText)
        {
            Button button = new Button
            {
                Name = menuName,
                Text = menuText,
                Height = 50,
                Dock = DockStyle.Top,
                FlatStyle = FlatStyle.Popup,
                Margin = new Padding(0)
            };
            this.plMenu.Controls.Add(button);
            button.Click += Btn_Click;
        }
        private void Btn_Click(object sender, EventArgs e)
        {
            foreach (Control item in this.plMain.Controls)
            {
                this.plMain.Controls.Remove(item);
            }
            Form formControl = new Form();
            switch (((Button)sender).Name)
            {
                case "sqlConfig":
                    formControl = new FmSQLConfig(ConfigCode.Main);
                    break;
                case "userSetting":
                    formControl = new FmUserSetting();
                    break;
                case "Columns":
                    formControl = new FmColumn();
                    break;
                case "Dictionary":
                    formControl = new FmDictionary();
                    break;
            }
            formControl.TopLevel = false;
            formControl.BackColor = this.plMain.BackColor;
            formControl.Dock = DockStyle.Fill;
            formControl.Show();
            this.plMain.Controls.Add(formControl);

        }
    }
}
